<?php
namespace StarCloud\Library;

use Framework\DiServices\Redis;
use Phalcon\Di;

class HashRedis
{
    /**
     * @var Redis
     */
    private $redis;
    private $key;

    public function __construct($key)
    {
        $this->redis = Di::getDefault()->get('redis');
        $this->key = $key;
    }

    public static function instance($key)
    {
        return new self($key);
    }

    public function hIncrBy($hashKey)
    {
        return $this->redis->hIncrBy($this->key, $hashKey, 1);
    }

    public function hSet($hashKey, $value)
    {
        $this->redis->hSet($this->key, $hashKey, $value);
    }

    public function hGet($hashKey)
    {
        return $this->redis->hGet($this->key, $hashKey);
    }

    public function hMGet($hashKeys)
    {
        return $this->redis->hMGet($this->key, $hashKeys);
    }

    public function hExists($hashKey)
    {
        return $this->redis->hExists($this->key, $hashKey);
    }
}
